﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Subfaculty.Common.Entities;
using Subfaculty.WebApplication.Translators;
using Subfaculty.WebApplication.ViewModels;

namespace Test.WebApplication.Translators
{
	[TestClass]
	public class DisciplineTranslatorTest
	{
		private DisciplineTranslator _translator;

		[TestInitialize]
		public void TestInit()
		{
			_translator = new DisciplineTranslator();
		}

		[TestMethod]
		public void ReturnDisciplineViewModelOnTranslateDiscipline()
		{
			var source = new Discipline()
			                 	{
									Id = 1,
			                 		Title = "Теория автоматов",
			                 		Abbreviation = "ТА"
			                 	};

			var pe = _translator.Translate(source);

			Assert.AreEqual(source.Id, pe.Id);
			Assert.AreEqual(source.Title, pe.Title);
			Assert.AreEqual(source.Abbreviation, pe.Abbreviation);
		}

		[TestMethod]
		public void ReturnDisciplineOnTranslateBackDisciplineViewModel()
		{
			var pe = new DisciplineViewModel()
			{
				Id = 2,
				Title = "Теория автоматов",
				Abbreviation = "ТА"
			};

			var source = new Discipline();
			_translator.TranslateBack(pe, source);

			Assert.AreEqual(pe.Id, source.Id);
			Assert.AreEqual(pe.Title, source.Title);
			Assert.AreEqual(pe.Abbreviation, source.Abbreviation);
		}
	}
}
